package com.neuedu.io;


import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * @author 金山
 * 项目：javase
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/10/3111:56
 */
public class MyScanner {

    StringBuffer  buffer = new StringBuffer();
    InputStream in;

    private static final byte SPACE = ' ';



    public MyScanner(InputStream in) {
        this.in = in;
    }

    //  100
    public int nextInt() throws IOException {

        buffer.delete(0,buffer.length());

        // InputStream in = System.in;
        byte bt;

        do{
            bt =  (byte) in.read();
            System.out.println("bt"+ bt);
            if(bt == SPACE || bt == 10){
                break;
            }

            buffer.append((char)bt);

        }while (true);

        //讲字符串的表示形式 转成 数字
        return Integer.parseInt(buffer.toString());
    }



    public static void main(String[] args) throws IOException {

        MyScanner scanner = new MyScanner(System.in);


        System.out.println("请输入两个数字，中间用空格分隔 如： 123 456");

        //获取第1个数字
        int nums1 = scanner.nextInt();

        // 获取第2个数字
        System.out.println("获取第2个数字");
        int nums2 = scanner.nextInt();

        System.out.println("nums1 = " + nums1);
        System.out.println("nums2 = " + nums2);


    }



}
